#include <iostream>
#include <pthread.h>
#include <unistd.h>

using namespace std;

// 新线程
void *threadRoutine(void *args)
{
    int count = 5;
    while (count)
    {
        count--;
        sleep(1);
    }
    pthread_exit((void*)100);
}

int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, threadRoutine, nullptr);

    pthread_cancel(tid);

    void* retval;
    pthread_join(tid,&retval);

    cout<<"线程等待成功："<<(long long)retval<<endl;
    return 0;
}